package com.ruibang.glass.iso.service.impl.impl;

import com.alibaba.excel.util.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruibang.glass.iso.domain.req.FileCategoryReq;
import com.ruibang.glass.iso.entity.FileCategory;
import com.ruibang.glass.iso.mapper.FileCategoryMapper;
import com.ruibang.glass.iso.service.impl.FileCategoryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * @Author: songJinKang
 * @CreateTime: 2024-06-05  15:44
 * @Description: TODO
 * @Version: 1.0
 */

@Slf4j
@Service
public class FileCategoryServiceImpl extends ServiceImpl<FileCategoryMapper, FileCategory> implements FileCategoryService {
    @Override
    public IPage<FileCategory> pageQuery(FileCategoryReq fileCategoryReq) {
        QueryWrapper<FileCategory> qw = new QueryWrapper<>();
        qw.lambda().eq(StringUtils.isNotBlank(fileCategoryReq.getLevel()), FileCategory::getLevel, fileCategoryReq.getLevel());
        qw.lambda().like(StringUtils.isNotBlank(fileCategoryReq.getCode()), FileCategory::getCode, fileCategoryReq.getCode());
        qw.lambda().like(StringUtils.isNotBlank(fileCategoryReq.getName()), FileCategory::getName, fileCategoryReq.getName());
        return this.page(new Page<>(fileCategoryReq.getPageNo(), fileCategoryReq.getPageSize()), qw);
    }
}
